// Package webmanage @author <chengjiang@buffalo-robot.com>
// @date 2023/2/21
// @note
package webmanage

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"gorm.io/gorm"
	"phm/models/generator/model"
)

type SysOperationRepo interface {
	CreateSysOperation(ctx context.Context, uModel *model.SysOperation, db *gorm.DB) error
	UpdateSysOperation(ctx context.Context, uModel *model.SysOperation, db *gorm.DB) error
	DeleteSysOperationByIds(ctx context.Context, ids []string, db *gorm.DB) error
	GetSysOperationById(ctx context.Context, id string) (*model.SysOperation, error)
	GetSysOperationByIds(ctx context.Context, ids []string) ([]*model.SysOperation, error)
	// GetDB 得到db以方便事务处理
	GetDB() *gorm.DB
	GetSysOperationByRoleId(ctx context.Context, roleId string) ([]*model.SysOperation, error)
}

type SysOperationUseCase struct {
	operationRepo SysOperationRepo
	log           *log.Helper
}

func NewSysOperationUseCase(repo SysOperationRepo, logger log.Logger) *SysOperationUseCase {
	return &SysOperationUseCase{
		operationRepo: repo,
		log:           log.NewHelper(logger),
	}
}
